﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using GH.Model;

public class SessionData
{
    public static string UserNum
    {
        get
        {
            return GetInfo().用户ID;
        }
    }
    public static int RightID
    {
        get
        {
            return GetInfo().角色ID;
        }
    }
    public static int? UserID
    {
        get
        {
            return GetInfo().ID;
        }
    }
    public static string ClientIP
    {
        get
        {
            return HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
        }
    }
    public static bool IsTimeout()
    {
        try
        {
            用户信息 info = GetInfo();
            return false;
        }
        catch
        {
            return true;
        }
    }
    public static void Set(用户信息 info)
    {
        HttpContext.Current.Session["USERINFO"] = info;
    }

    private static 用户信息 GetInfo()
    {
        if (HttpContext.Current.Session["SITEINFO"] == null)
            throw new Exception("您没有登录系统或会话已过期,请重新登录");
        //return (GlobalUserInfo)HttpContext.Current.Session["SITEINFO"];
        else
            return (用户信息)HttpContext.Current.Session["USERINFO"];

    }
}
